package fi.profecons.csswindows.toolkit;

import fi.profecons.csswindows.Element;

public class Input extends Element {

	private String value = new String();

	private boolean enabled = true;

	private String type;

	private String name;

	public Input() {
		super();
		this.type = "text";
		addCommand("new Input('" + getId() + "');");
		if (!isEnabled()) {
			addCommand("getElement('" + getId() + "').disable();");
		}
	}

	public Input(String type, String name) {
		this.name = name;
		this.type = type;
		addCommand("new Input('" + getId() + "', '" + type +"', '" + name + "');");
		if (!isEnabled()) {
			addCommand("getElement('" + getId() + "').disable();");
		}
	}
	
	public Input(String type){
		this.type = type;
		addCommand("new Input('" + getId() + "', '" + type +"');");
		if (!isEnabled()) {
			addCommand("getElement('" + getId() + "').disable();");
		}
	}

	public String getValue() {
		return value;
	}

	public void disable() {
		enabled = false;
		addCommand("getElement('" + getId() + "').disable();");
	}

	public void enable() {
		enabled = true;
		addCommand("getElement('" + getId() + "').enable();");
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setValue(String value) {
		this.value = value;
		addCommand("getElement('" + getId() + "').setValue('" + value + "');");
	}

	public String getType() {
		return type;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public String getName() {
		return name;
	}
}
